import QtQuick
import QtQuick.Controls

Pane {
    id: root
    anchors.fill: parent

    Text {
        id: mainText
        anchors.centerIn: parent
        text: "右键点击显示上下文菜单"
        font.pixelSize: 16
    }

    Menu {
        id: contextMenu
        
        MenuItem {
            text: "复制"
            onTriggered: console.log("复制被点击")
        }
        MenuItem {
            text: "粘贴"
            onTriggered: console.log("粘贴被点击")
        }
        MenuItem {
            text: "剪切"
            onTriggered: console.log("剪切被点击")
        }
        MenuSeparator { }
        MenuItem {
            text: "刷新"
            onTriggered: console.log("刷新被点击")
        }
    }

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.RightButton
        onClicked: function(mouseEvent) {
            if (mouseEvent.button === Qt.RightButton) {
                contextMenu.popup()
            }
        }
    }
}
